import gradio as gr
from PIL import Image

def get_coords(image, select_data):
    # select_data: {'x':..., 'y':..., 'width':..., 'height':...}
    print(select_data)
    return select_data

demo = gr.Interface(
    fn=get_coords,
    inputs=gr.Image(type="pil", tool="select", label="框选区域"),
    outputs="json",
)

# demo.launch()

demo.launch(
    server_name='0.0.0.0',
    server_port=20022)